//
//  HomeMessageCell.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/25.
//

#import "HomeMessageCell.h"

@interface HomeMessageCell()
@property (nonatomic,strong) UIView * bgView;
@property (nonatomic,strong) UIImageView * iconView;
@property (nonatomic,strong) UILabel * nameLabel;
@property (nonatomic,strong) UILabel * timeLabel;
@property (nonatomic,strong) UILabel * infoLabel;
@property (nonatomic,strong) UIView * lineView;
@property (nonatomic,strong) UILabel * descLabel;
@property (nonatomic,strong) UIImageView * arrow;
@end

@implementation HomeMessageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setSubViewLayout];
    }
    return self;
}

-(void)setSubViewLayout{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    
    [self addSubview:self.bgView];
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self).insets(UIEdgeInsetsMake(6 * FMScaleX, 16 * FMScaleX, 6* FMScaleX, 16 * FMScaleX));
    }];
    
    [self.bgView addSubview:self.iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(24 * FMScaleX, 24 * FMScaleX));
        make.left.mas_offset(16 * FMScaleX);
        make.top.mas_offset(16 * FMScaleX);
    }];
    [self.bgView addSubview:self.nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).offset(10 * FMScaleX);
        make.centerY.equalTo(self.iconView);
    }];
    [self.bgView addSubview:self.timeLabel];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-16 * FMScaleX);
        make.centerY.equalTo(self.iconView);
    }];
    [self.bgView addSubview:self.infoLabel];
    [_infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(312 * FMScaleX, 60 * FMScaleX));
        make.top.equalTo(self.nameLabel.mas_bottom).offset(8 * FMScaleX);
        make.centerX.equalTo(@0);
    }];
    [self.bgView addSubview:self.lineView];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(300 * FMScaleX, 1 * FMScaleX));
        make.top.equalTo(self.infoLabel.mas_bottom).offset(15 * FMScaleX);
        make.centerX.equalTo(@0);
    }];
    [self.bgView addSubview:self.descLabel];
    [_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView);
        make.top.equalTo(self.lineView.mas_bottom).offset(12 * FMScaleX);
    }];
    [self.bgView addSubview:self.arrow];
    [_arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-16 * FMScaleX);
        make.centerY.equalTo(self.descLabel);
        make.size.mas_offset(CGSizeMake(24 * FMScaleX, 24 * FMScaleX));
    }];
}
-(UIView *)bgView{
    
    if (!_bgView) {
        _bgView = [[UIView alloc]init];
        _bgView.backgroundColor = UIColor.whiteColor;
    }
    return _bgView;
}

-(UIImageView *)iconView{
    
    if (!_iconView) {
        _iconView = [[UIImageView alloc]init];
    }
    return _iconView;
}

-(UILabel *)nameLabel{
    
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = Bold(17 * FMScaleX);
        _nameLabel.textColor = RDRGB(0x333333);
        _nameLabel.text = @"兑换公示";
    }
    return _nameLabel;
}
-(UILabel *)timeLabel{
    
    if (!_timeLabel ) {
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.font = Regular(15 * FMScaleX);
        _timeLabel.textColor = RDRGB(0x999999);
        _timeLabel.text = @"06/02";
    }
    return _timeLabel;
}
-(UILabel *)infoLabel{
    
    if (!_infoLabel) {
        _infoLabel = [[UILabel alloc]init];
        _infoLabel.textColor = RDRGB(0x999999);
        _infoLabel.font = Regular(15 * FMScaleX);
        _infoLabel.text = @"本周四上午十点准时开始水滴币兑换贵州茅台酒活动，299个草药币即可参加，库存400瓶，抢完为止，快来报名参加吧～";
        _infoLabel.numberOfLines = 0;
    }
    return _infoLabel;
}
-(UIView *)lineView{
    
    if (!_lineView) {
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = RDRGB(0xF7F6F4);
    }
    return _lineView;
}
-(UILabel *)descLabel{
    
    if (!_descLabel) {
        _descLabel = [[UILabel alloc]init];
        _descLabel.font = Bold(16 * FMScaleX);
        _descLabel.textColor = RDRGB(0x555555);
        _descLabel.text = @"查看详情";
    }
    return _descLabel;
}
-(UIImageView *)arrow{
    
    if (!_arrow) {
        _arrow = [[UIImageView alloc]init];
        _arrow.image = [UIImage imageNamed:@"Me_head_arrow"];
    }
    return _arrow;
}
@end
